package com.yaorange.api;


import com.yaorange.common.core.domain.AjaxResult;
import com.yaorange.nongit.domain.NjtArea;
import com.yaorange.nongit.service.INjtAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/area")
public class NjtAreaAPI {

    @Autowired
    private INjtAreaService njtAreaService;

    @RequestMapping("/queryListRoot")
    public AjaxResult queryListRoot(@RequestParam(value = "parentCode", required = false)
                                       String parentCode){
        List<NjtArea> code = njtAreaService.getByParentCode(parentCode);
        return AjaxResult.success(code);
    }


    @RequestMapping("/queryChildrenByParentCode")
    public AjaxResult queryChildrenByParentCode(@RequestParam(value = "parentCode", required = false)
                                                        String parentCode){
        List<NjtArea> code = njtAreaService.getByParentCode(parentCode);
        return AjaxResult.success(code);
    }
}
